package com.xpresso.utils.files;

import java.io.*;

import com.xpresso.utils.exceptions.XpressoException;

public class FileReader {

	public String readFile(String path) throws XpressoException{
      StringBuffer sb = new StringBuffer();
		try {
		    FileInputStream fstream = new FileInputStream(path);
		    // Get the object of DataInputStream

		    DataInputStream in = new DataInputStream(fstream);
		    BufferedReader br = new BufferedReader(new InputStreamReader(in));
		    String strLine;
		    //Read File Line By Line
		    
		    while ((strLine = br.readLine()) != null)   {
		      // Print the content on the console
		      sb.append(strLine + "\n");
		    }
		    //Close the input stream
		    in.close();
	   }catch (Exception e){
	      throw new XpressoException("Error reading file", e);
	   }
	   return sb.toString();
	}
	
	
}
